/*-
 * Copyright (c) 2007 Microsoft
 * All rights reserved.
 */

#include "StdAfx.h"
#include "MPIException.h"

using namespace Microsoft::ComputeCluster::MpiNet;
using namespace System;

///<summay>
///Construct a MPI exception from a MPI error code.
///</summay>
MPIException::MPIException(int retcode)
{
    this->code = retcode;
}

///<summay>
///Get the error message based on the error code
///</summay>
String^ MPIException::Message::get()
{
    char buffer[MPI_MAX_ERROR_STRING];
    int len;
    MPI_Error_string(this->code, buffer, &len);

    return gcnew String(buffer);
}

///<summay>
///Get the MPI Error code.
///</summay>
int MPIException::ErrorCode::get()
{
    return this->code;
}

///<summay>
///Override ToString() to return error message.
///</summay>
String^ MPIException::ToString()
{
    return this->Message::get();
}